<?php

namespace app\site\controller\open;

use app\common\exception\MiException;
use thans\jwt\facade\JWTAuth;

class PublicController
{

    /** 刷新token
     * @throws MiException
     */
    public function refreshToken(): \think\response\Json
    {

        try {
            // 尝试刷新token
            $token = JWTAuth::refresh();
        }catch (\Exception $e){
            return jsonError("刷新令牌失败");
        }

        return jsonSuccess([
            'token' => $token
        ]);
    }

}
